package ooday03;

public class RafArrayDemo {
    public static void main(String[] args) {
        /*
        //声明Dog类型数组dogs,包含3个元素,每个元素都是Dog类型,默认值为null
        Dog[] dogs=new Dog[3];
        //声明Chick类型数组chicjs,包含3个元素,每个元素都是Chick类型,默认值为null
        Chick[] chicks=new Chick[3];
        //声明Fish类型数组fishs,包含了2个元素,每个元素都是Fish类型,默认值为null
        Fish[] fishs=new Fish[3];
         */

        int[] arr=new int[3];
        arr[1]=(1);
        //声明Dog类型数组dogs,包含3个元素,每个元素都是Dog类型
        Dog[] dogs=new Dog[3];
        dogs[0]=new Dog("黑",1,"蔡徐坤");//给数组元素添加内容
        dogs[1]=new Dog("黄",2,"小黑");
        dogs[2]=new Dog("蓝",3,"小蓝");
        for(int i=0;i<dogs.length;i++){//遍历数组
            System.out.println(dogs[i].name);//输出名字
            dogs[i].eat();//输出在eat这个方法
        }
        System.out.println();
        Chick[] chick=new Chick[2];
        chick[0]=new Chick("绿",1,"小绿");
        chick[1]=new Chick("黑",2,"小黑");
        for(int i=0;i<chick.length;i++){
            System.out.println(chick[i].name);
            chick[i].eat();
        }
        System.out.println();
        Fish[] fish=new Fish[2];
        fish[0]=new Fish("黑",1,"雯雯");
        fish[1]=new Fish("绿",2,"小强");
        for (int i=0;i<fish.length;i++){
            System.out.println(fish[i].name);
            fish[i].eat();
        }
    }
}
